<?php
class PNTopOnsaleArray extends PNObjectExArray {
  function PNTopOnsaleArray($init=null, $where='')
  {
    $this->PNObject();

    $this->_objType       = 'innoforum_topics';
    $this->_objField      = 'id';
    $this->_objPath       = 'form';
    $this->_objColumnExArray = array( 'is_new'      => "IF ( DATEDIFF(DATE(tpc_cr_date),DATE(NOW())) <1 
                                                             AND
                                                             DATEDIFF(DATE(tpc_cr_date),DATE(NOW())) >-3,
                                                            'T','F')");
/*
    $this->_objJoin[]     = array ( 'join_table'  =>  'innoforum_type',
                            'join_field'          =>  array('name'),
                            'object_field_name'   =>  array('type_name'),
                            'compare_field_table' =>  'type_id',
                            'compare_field_join'  =>  'id');

    $this->_objJoin[]     = array ( 'join_table'  =>  'innoforum_category',
                            'join_field'          =>  array('name'),
                            'object_field_name'   =>  array('category_name'),
                            'compare_field_table' =>  'category_id',
                            'compare_field_join'  =>  'id');

   $this->_objJoin[]     = array ( 'join_table'  =>  'innoforum_subcategory',
                            'join_field'          =>  array('name'),
                            'object_field_name'   =>  array('subcategory_name'),
                            'compare_field_table' =>  'subcategory_id',
                            'compare_field_join'  =>  'id');

    $this->_objJoin[]     = array ( 'join_table'  =>  'innoforum_posts',
                            'join_field'          =>  array('id'),
                            'object_field_name'   =>  array('post_id'),
                            'compare_field_table' =>  'id',
                            'compare_field_join'  =>  'topics_id');
    $this->_init($init, $where);
*/
  }
  function genSort(){

      //default order
      return 'ORDER BY tpc_cr_date DESC';
  
  }

  function genFilter(){
    $where = array();
    $where[] = "tpc_cr_uid = '2' ";
    $where[] = "tpc_onsale = 1 ";
    $where[] = "tpc_onsale_viewpoint = 1 ";
    return implode(' AND ', $where);
  }

  function selectExtendResult(){
    $id = FormUtil::getPassedValue ('id', false);
    //$result = array();
    if ($id){ 
      return DBUtil::selectObject('innoforum_resource_image', "WHERE rsi_referer_id = '$id' and rsi_status = 1",array("filename","thumbname"));
    }
  }

}